<?php
//[构造函数]
//00. https://zhidao.baidu.com/question/541896971.html
//01. 创建一个类求正边形面积
class demo {
public $length=0; //长度
public $area; //面积

public function __construct($length) {
$this->length = $length;
$this->area = $this->length * $this->length;
}

public function __destruct(){
echo "<br/>对象已经销毁或者php代码运行完毕<br/>";
}

}

//02. 用类定义一个新对象
$demo = new demo("6");
echo $demo->area;
unset($demo);
echo $demo->area;
?>